<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.ownershipstatistic.OwnershipStatisticVO"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>机动车保有量查询</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="<%=request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css"/>
  </head>
  <%
   	int pageon = 0;
  	int total = 0;
  	int count = 0;
  	String village ="";
  	if(request.getAttribute("pageon")!=null){
  		pageon = (Integer)request.getAttribute("pageon");
  	}
  	if(request.getAttribute("total")!=null){
  		total = (Integer)request.getAttribute("total");
  	}
  	if(request.getAttribute("count")!=null){
  		count = (Integer)request.getAttribute("count");
  	}
  	if(request.getAttribute("village")!=null){
  		village = (String)request.getAttribute("village");
  	}
  	if(total==0){
  		pageon=0;
  	}
  	List queryList = (List)request.getAttribute("queryList");
   %>  
  <body bgcolor="#DBEAF9">
  	<jsp:include flush="true" page="/common/menu.html"></jsp:include>
     <form action="<%=path %>/system/ownershipstatistic_query.action" method="post">
   		<h1 align="center">机动车保有量查询</h1>
   		<table align="center" class="my-table">
   			<tr>
   				<td>
   					屯名称：<input type="text" name="ownershipStatisticVO.village" value="<%=village %>"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   					<input name="submit" type="submit" value="查询" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   					<input type="button" value="打印选中信息" onclick="fun_print()"/>
   					<input type="button" value="导入信息" onclick="submit1()"/>
   				</td>
   			</tr>
   		</table>
   	</form>
   		<form id="print1Form" name="print1Form" action="<%=path %>/system/ownershipstatistic_print.action" method="post">
   		<input type="hidden" name="printIds" id="printIds"/>
   		<table align="center" class="my-table">
   			<tr>
   				<th>序号</th>
   				<th>屯</th>
   				<th>屯长</th>
   				<th>联系电话</th>
   				<th>摩托车</th>
   				<th>三轮车</th>
   				<th>农用四轮车</th>
   				<th>小型车</th>
   				<th>大型车</th>
   				<th>总数</th>
   				<th>打印状态</th>
   				<th>选择</th>
   			</tr>
   			<%
   				if(queryList!=null&&queryList.size()>0){
   					for(int i=0;i<queryList.size();i++){
   						OwnershipStatisticVO vo = (OwnershipStatisticVO)queryList.get(i);
   			%>
	   			<tr>
	   				<td><%=i+1 %></td>
	   				<td><%=vo.getVillage() %></td>
	   				<td><%=vo.getVillagehead() %></td>
	   				<td><%=vo.getPhonenumber() %></td>
	   				<td><%=vo.getMotorcycle() %></td>
	   				<td><%=vo.getTricycle() %></td>
	   				<td><%=vo.getFarmtransporter() %></td>
	   				<td><%=vo.getCar() %></td>
	   				<td><%=vo.getBus() %></td>
	   				<td><%=vo.getSum() %></td>
	   				<%
	   				if(vo.getPrint()==1) {
	   				%>
	   				<td>已打印</td>
	   				<%}else{%>
	   				<td>未打印</td>
	   				<%}%>
	   				<td><label><input type="checkbox" name="id" value="<%=vo.getId()%>" /></label></td>
	   			</tr>
   			<%
   					}
   				}
   			 %>
   			<tr>
				<th colspan="12" align="right"> 　
					<input type="checkbox" name="ids" value="on" onclick="CheckAll(this.form);" />选定所有记录
				</th>
			</tr>
			<tr>
	          <td colspan="12" align="right">
					共<%=total %>页&nbsp;&nbsp;&nbsp;第<%=pageon %>页
					<%if(total>0){
						if(pageon != 1) { %>
							<a href="<%=path %>/system/ownershipstatistic_query.action?ownershipStatisticVO.pageon=1&ownershipStatisticVO.village=<%=village %>">第一页</a> 
							<a href="<%=path %>/system/ownershipstatistic_query.action?ownershipStatisticVO.pageon=<%=(pageon - 1) %>&ownershipStatisticVO.village=<%=village %>">上一页</a>
						<%} %>
						<%if(pageon != total) { %>
							<a href="<%=path %>/system/ownershipstatistic_query.action?ownershipStatisticVO.pageon=<%=(pageon + 1) %>&ownershipStatisticVO.village=<%=village %>">下一页</a> 
							<a href="<%=path %>/system/ownershipstatistic_query.action?ownershipStatisticVO.pageon=<%=total %>&ownershipStatisticVO.village=<%=village %>">最后一页</a>
						<%} 
					}%>
	          </td>
	        </tr>
   		</table>
  	</form>
<script>
	function CheckAll(form) {
		for(var i = 0;i < form.elements.length;i++) {   
		    var e = form.elements[i];
		    
		    if(e.name != "ids") {
		    	e.checked = form.ids.checked;
		    }
		}
	}
	
	function submit1() {
		window.showModalDialog("<%=path %>/ownershipstatistic/import.jsp",window,"status:no;scroll:no;dialogWidth:245px;dialogHeight:120px"); 
	}
	var msg="${requestScope.msg}";
	if(msg!=""){
		alert(msg);
		window.close();
	}
	function fun_print() {
		var prints = "";
		var ids = document.getElementsByName("id");
		for(var i = 0;i < ids.length;i++) {   
	    	if (ids[i].checked) {
	    		prints += ids[i].value + ",";
	    	}
		}
		if (prints!="") {
			document.getElementById('printIds').value = prints.substring(0, prints.length-1);
		} else {
			alert('请先选择数据');
			return;
		}
		document.getElementById('print1Form').submit();
	}
</script>
  </body>
</html>
